using System.Collections.Generic;
using Bingo.LocalDB;
using Bingo.LocalDB.Entity;

namespace Bingo.API.LocalDB
{
    public interface ILocalDB
    {
        void Load();
        
        /// <summary>
        /// 删除数据库，IBoxDB中没有直接删除一个表的接口，所以这个方法显得格外亲切~
        /// 注意：删除数据库之前要关闭该数据库
        /// </summary>
        /// <param name="address">数据库地址</param>
        void DeleteDataBase(int address);

        /// <summary>
        /// 存储一个列表的数据
        /// </summary>
        /// <param name="tableName">向哪个表存数据</param>
        /// <param name="data">要存储的数据集合</param>
        void Save(string tableName, List<BaseObject> data);

        /// <summary>
        /// 存储一个对象的数据
        /// </summary>
        /// <param name="tableName">向哪个表存数据</param>
        /// <param name="ob">数据</param>
        void Save(string tableName, BaseObject ob);


        /// <summary>
        /// 获取数据
        /// </summary>
        /// <param name="QL">QL语句</param>
        /// <param name="param">QL参数</param>
        /// <returns></returns>
        List<BaseObject> Get(string QL, string param);

        List<BaseObject> GetAll(string QL, string param);

        BaseObject GetById(string id);

        void Save(string key, object value);

        K Get<K>(string key) where K : new();

        K Get<K>(string key, K @default) where K : new();
        
        List<BaseObject> GetByType(string type);
        
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="data"></param>
        /// <typeparam name="T"></typeparam>
        void Insert<T>(T data) where T : BaseEntity;

        void Insert<T>(List<T> list) where T : BaseEntity;

        void Update<T>(T data) where T : BaseEntity;

        void Delete<T>(long Id) where T : BaseEntity;

        List<T> GetAll<T>() where T : BaseEntity, new();

        T GetById<T>(long Id) where T : BaseEntity, new();

        T GetByParam<T>(string key, object value) where T : BaseEntity, new();

        bool DeleteAll<T>() where T : BaseEntity;

        bool Delete(string id);
    }
}